﻿<Window x:Class="SnowmanConsulting.ProductKeyManager.UI.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ui="clr-namespace:SnowmanConsulting.ProductKeyManager.UI"
    xmlns:data="clr-namespace:SnowmanConsulting.ProductKeyManager.Data;assembly=SnowmanConsulting.ProductKeyManager.Data"
    xmlns:uic="clr-namespace:SnowmanConsulting.UIControls;assembly=SnowmanConsulting.UIControls"
    x:Uid="MainWindow.Title" Style="{DynamicResource MainWindow}" Background="Transparent"
    Title="Product Key Manager">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/MainWindowResources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <DataTemplate DataType="{x:Type data:Product}">
                <StackPanel Style="{StaticResource ProductItemContainer}" ToolTip="{Binding Path=Name}">
                    <StackPanel Orientation="Vertical">
                        <Image Style="{StaticResource ProductItemIcon}" Source="{Binding Path=Icon.Image}"/>
                        <TextBlock Style="{StaticResource ProductItemName}" Text="{Binding Path=Name}"/>
                        <TextBlock Style="{StaticResource ProductItemKeys}">
                            <TextBlock x:Uid="MainWindow.ProductDataTemplate.Keys" Text="Keys: "/>
                            <TextBlock Text="{Binding Path=Keys.Count}"/>
                        </TextBlock>
                    </StackPanel>
                </StackPanel>
            </DataTemplate>
        </ResourceDictionary>
    </Window.Resources>
    <DockPanel>
        <Border DockPanel.Dock="Top" Name="MenuDock" BorderThickness="0,0,0,2">
            <DockPanel>
                <StackPanel DockPanel.Dock="Right">
                    <uic:SearchTextBox Name="SearchBox" SearchMode="Instant" Margin="1" Width="200" Height="21"/>
                </StackPanel>
                <Menu Name="MainMenu" DockPanel.Dock="Top" Background="Transparent">
                    <MenuItem x:Uid="MainWindow.Menu.File" Header="_File" Style="{StaticResource RootMenuItem}">
                        <MenuItem x:Uid="MainWindow.Menu.File.New" Name="MenuFileNew" Click="NewButtonClicked" Header="_New"/>
                        <Separator/>
                        <MenuItem x:Uid="MainWindow.Menu.File.Import" Name="MenuFileImport" Header="_Import" Click="ImportButtonClicked"/>
                        <MenuItem x:Uid="MainWindow.Menu.File.Export" Header="E_xport" Click="ExportButtonClicked" />
                        <Separator/>
                        <MenuItem x:Uid="MainWindow.Menu.File.Exit" Name="MenuFileExit" Click="FileMenuExitClicked" Header="_Exit" />
                    </MenuItem>
                    <MenuItem x:Uid="MainWindow.Menu.Edit" Name="MenuEdit" Visibility="Collapsed" Click="EditButtonClicked" Header="_Edit" Style="{StaticResource RootMenuItem}" />
                    <MenuItem x:Uid="MainWindow.Menu.View" Header="_View" Style="{StaticResource RootMenuItem}">
                        <MenuItem x:Uid="MainWindow.Menu.View.Sort" Header="_Sort">
                            <MenuItem x:Uid="MainWindow.Menu.View.Sort.Name" Header="Name">
                                <MenuItem x:Uid="MainWindow.Menu.View.Sort.Name.None" Name="MenuViewSortNameNone" Click="OnNameSort" Header="None" IsCheckable="True" IsChecked="True" />
                                <MenuItem x:Uid="MainWindow.Menu.View.Sort.Name.Asc" Name="MenuViewSortNameAsc" Click="OnNameSort" Header="Ascending" IsCheckable="True" />
                                <MenuItem x:Uid="MainWindow.Menu.View.Sort.Name.Dsc" Name="MenuViewSortNameDsc" Click="OnNameSort" Header="Descending" IsCheckable="True" />
                            </MenuItem>
                            <MenuItem x:Uid="MainWindow.Menu.View.Sort.KeyCount" Header="Key Count">
                                <MenuItem x:Uid="MainWindow.Menu.View.Sort.KeyCount.None" Name="MenuViewSortKeyCountNone" Click="OnKeyCountSort" Header="None" IsCheckable="True" IsChecked="True" />
                                <MenuItem x:Uid="MainWindow.Menu.View.Sort.KeyCount.Asc" Name="MenuViewSortKeyCountAsc" Click="OnKeyCountSort" Header="Ascending" IsCheckable="True" />
                                <MenuItem x:Uid="MainWindow.Menu.View.Sort.KeyCount.Dsc" Name="MenuViewSortKeyCountDsc" Click="OnKeyCountSort" Header="Descending" IsCheckable="True" />
                            </MenuItem>
                        </MenuItem>
                    </MenuItem>
                    <MenuItem x:Uid="MainWindow.Menu.Tools" Header="_Tools" Style="{StaticResource RootMenuItem}">
                        <MenuItem x:Uid="MainWindow.Menu.Tools.Settings" Name="MenuToolsSettings" Header="Settings" Click="ToolsSettings_Click">
                            <MenuItem.Icon>
                                <Image Style="{StaticResource SettingsMenuIcon}"/>
                            </MenuItem.Icon>
                        </MenuItem>
                        <MenuItem Name="MenuToolsLogViewer" Header="Log Viewer" Click="MenuToolsLogViewer_Click"/>
                    </MenuItem>
                    <MenuItem x:Uid="MainWindow.Menu.Help" Header="_Help" Style="{StaticResource RootMenuItem}">
                        <MenuItem x:Uid="MainWindow.Menu.Help.About" Name="MenuHelpAbout" Header="_About" Click="MenuHelpAboutClicked">
                            <MenuItem.Icon>
                                <Image Style="{StaticResource AboutMenuIcon}"/>
                            </MenuItem.Icon>
                        </MenuItem>
                    </MenuItem>
                </Menu>
            </DockPanel>
        </Border>
        <Border BorderThickness="1" DockPanel.Dock="Top" BorderBrush="#B6D1D8">
            <Border.Background>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" >
                    <GradientStop Color="#89B7C1" Offset="0" />
                    <GradientStop Color="#498F9F" Offset="0.49" />
                    <GradientStop Color="#166577" Offset="0.50" />
                    <GradientStop Color="#55A2AB" Offset="1" />
                </LinearGradientBrush>
            </Border.Background>
            <ToolBar Height="28" Style="{StaticResource VistaStyleToolbar}" ToolBarTray.IsLocked="True"  Background="Transparent">
                <Button Background="Transparent" BorderThickness="0" Height="18" Click="NewButtonClicked" ToolTip="Add Product">
                    <DockPanel>
                        <TextBlock DockPanel.Dock="Right" Style="{StaticResource ToolbarButtonText}" Text="Add"/>
                        <Image Style="{StaticResource NewToolbarIcon}"/>
                    </DockPanel>
                </Button>
                <Button Name="DeleteButton" Visibility="Collapsed" ToolTip="Delete Selected Product(s)" Click="DeleteButtonClicked">
                    <DockPanel>
                        <TextBlock DockPanel.Dock="Right" Style="{StaticResource ToolbarButtonText}" Text="Remove"/>
                        <Image Style="{StaticResource DeleteToolbarIcon}"/>
                    </DockPanel>
                </Button>
                <Button Name="EditButton" Visibility="Collapsed" ToolTip="Edit Selected Product" Click="EditButtonClicked">
                    <DockPanel>
                        <TextBlock DockPanel.Dock="Right" Style="{StaticResource ToolbarButtonText}" Text="Edit"/>
                        <Image Style="{StaticResource RenameToolbarIcon}"/>
                    </DockPanel>
                </Button>
                <Separator Background="#B6D1D8"/>
                <Button Background="Transparent" BorderThickness="0" Height="18" ToolTip="Import" Click="ImportButtonClicked">
                    <DockPanel>
                        <TextBlock DockPanel.Dock="Right" Style="{StaticResource ToolbarButtonText}" Text="Import"/>
                        <Image Style="{StaticResource ImportToolbarIcon}"/>
                    </DockPanel>
                </Button>
                <Button Background="Transparent" BorderThickness="0" Height="18" ToolTip="Export" Click="ExportButtonClicked">
                    <DockPanel>
                        <TextBlock DockPanel.Dock="Right" Style="{StaticResource ToolbarButtonText}" Text="Export"/>
                        <Image Style="{StaticResource ExportToolbarIcon}"/>
                    </DockPanel>
                </Button>
            </ToolBar>
        </Border>
        <ListBox Name="listProductKeys" Style="{StaticResource ProductList}" SelectionChanged="ProductKeysList_SelectionChanged" MouseDoubleClick="ProductKeysList_DoubleClicked" KeyDown="ListBoxKeyDown"  ItemsSource="{Binding}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel IsItemsHost="True" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
        </ListBox>
    </DockPanel>
</Window>
